// SuperGarbage Loader
// num _app
// 0: app0.bin
// 1: app1.bin
// 2: app2.bin
 SuperGarbageLoader: 
 
//final int num_app = 0;
.data
num_app:
.word 0

.bss
//word mem[4096];
.skip 4096
//word startPC;
.skip 4
 
// basic code stub
//set $SP;
/*WAHHHTTT DAA FUUUUUUUUUUUU*/

//set $GP;
/*WAHHHTTT DAA FUUUUUUUUUUUU*/
 
// select an app
//out( num_app, 1);
/*WAHHHTTT DAA FUUUUUUUUUUUU*/
 
// load data from an external device while(addr != -1)

//do {
doloop:

/////////////////////    word addr, data; //////////////////////////////
//    addr = in(0x1);
mov 0x1, %l0
call in
st	%rv, %l1

//    data = in(0x1);
mov 0x1, %l0
call in
st	%rv, %l2
   
//    if (addr == 0x3FFFFFFFFL) {
ifstmt:
mov 0x3FFFFFFFFL, %l3
bne %l1, %l3, else

//        startPC = data;
/*WAHHHTTT DAA FUUUUUUUUUUUU*/

//        break;
ba endwhile

//    } else {
else:

//        mem[addr] = data;
/*WAHHHTTT DAA FUUUUUUUUUUUU*/

/////////////////////////////    } /////////////////////////////
//} while(true);
ba doloop
endwhile:
 
// Finally, call the virtual machine
start = get_instr_count();
VirtualMachine(startPC, mem);
end = get_instr_count();
out (0x3,end - start);